package com.example.tse.rbyair.util;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferenceUtils {
	public static final String USERID = "";
	

	public static void putValueAndKey(Context context, String key, String value) {
		SharedPreferences sp = context.getSharedPreferences(key, 0);
		SharedPreferences.Editor editor = sp.edit();
		editor.putString(key, value);
		editor.commit();
	}
	
	public static void putValueAndKeyForInt(Context context, String key, int value){
		SharedPreferences sp = context.getSharedPreferences(key, 0);
		SharedPreferences.Editor editor = sp.edit();
		editor.putInt(key, value);
		editor.commit();
	}
	
	public static int getValueByKeyForInt(Context context, String key){
		return context.getSharedPreferences(key, 0).getInt(key, 0);
	}

	public static void removeKey(Context context, String key) {
		SharedPreferences sp = context.getSharedPreferences(key, 0);
		SharedPreferences.Editor editor = sp.edit();
		editor.remove(key);
		editor.commit();
	}

	public static String getValueByKey(Context context, String key) {
		SharedPreferences sp = context.getSharedPreferences(key, 0);
		if (sp == null ) {
			return null;
		}
		return sp.getString(key, "");
	}
	
	public static String getTecStringValueByKey(Context context, String key){
		if(context == null){
			return "-1";
		}else{
			return context.getSharedPreferences(key, Activity.MODE_PRIVATE).getString(key, "1");
			
		}
	}
	
	public static boolean getBooleanValueByKey(Context context, String key){
		return context.getSharedPreferences(key, 0).getBoolean(key, false);
	}
	
	public static void putBooleanValueByKey(Context context, String key, boolean value){
		SharedPreferences sp = context.getSharedPreferences(key, 0);
		SharedPreferences.Editor editor = sp.edit();
		editor.putBoolean(key, value);
		editor.commit();
	}
}
